package com.show.mytest;

public class LightThread implements Runnable{
    private Employee e;
    private int index = 0;
    public LightThread(Employee e) {
        this.e = e;
    }

    @Override
    public void run() {
        while (true){
            synchronized (e){
                if (index % 2 == 0){
                    e.setUsername("阿凡");
                    e.setSex("男");
                } else {
                    e.setUsername("阿梅");
                    e.setSex("女");
                }
                try {
                    e.notify();
                    e.wait();
                } catch (InterruptedException e1) {
                    e1.printStackTrace();
                }
            }
            index++;
        }
    }
}
